// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
import axios from 'axios'
import TreeTable from 'vue-table-with-tree-grid'
import VueQuillEditor from 'vue-quill-editor'
// 使用treetable
Vue.component('tree-table',TreeTable)

import 'quill/dist/quill.core.css' // import styles
import 'quill/dist/quill.snow.css' // for snow theme
import 'quill/dist/quill.bubble.css' // for bubble theme

Vue.prototype.$http = axios
// 请求的根路径
axios.defaults.baseURL= "http://timemeetyou.com:8889/api/private/v1/"
// 权限
axios.interceptors.request.use(config => {
  config.headers.Authorization = window.sessionStorage.getItem('token')
  return config
})
Vue.config.productionTip = false
Vue.use(ElementUI);
Vue.use(VueQuillEditor)
// Vue.prototype.$confirm = MessageBox.confirm

// 时间过滤器
Vue.filter('dateFormate', function(originVal){
  const da = new Date(originVal)
  // 年
  const y = da.getFullYear()
  // 月,padStart：第一个参数，几位：第二位参数，用什么补充
  const m = (da.getMonth() + 1 +'').padStart(2,'0')

  // 日
  const d = (da.getDay() +'').padStart(2,'0')

  // 小时
  const hh = (da.getHours() + '').padStart(2,'0')
  // 分钟
  const mm = (da.getMinutes() + '').padStart(2,'0')
  // 秒
  const ss = (da.getSeconds() + '').padStart(2,'0')

  return `${y}-${m}-${d} ${hh}:${mm}:${ss}`
  

})

/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  components: { App },
  template: '<App/>'
})
